package cn.sn.controller;

import cn.sn.dto.UserLoginDTO;
import cn.sn.result.R;
import cn.sn.service.IndexService;
import cn.sn.vo.LoginVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: SuNing
 * @date: 2023/9/19 19:31
 * @version: 1.0
 */

@Slf4j
@RestController
@RequestMapping("/index")
@RequiredArgsConstructor
public class LoginController  {

    private final IndexService indexService;

    /**
     * 登录
     *
     * @param userLoginDTO 用户登录dto
     * @return {@link R}<{@link ?}>
     */
    @PostMapping("/login")
    public R<LoginVO> login(@RequestBody UserLoginDTO userLoginDTO){
        LoginVO  loginVO =  indexService.login(userLoginDTO);
        return R.success(loginVO);
    }
}
